﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Button : ButtonBasic
{
    protected void State(bool value)
    {
        if (value != state)
        {
            state = value;
            AfterSwitchChanged();
        }
    }
    protected void Trig(Collider2D collision,bool value)
    {
        foreach (var item in charactors)
        {
            if (collision.gameObject.name == item.name)
            {
                State(value);
                return;
            }
        }
    }
    private void OnTriggerStay2D(Collider2D collision)
    {
        Trig(collision, true);
    }
    private void OnTriggerExit2D(Collider2D collision)
    {
        Trig(collision, false);
    }
}
